import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'

// https://vite.dev/config/
export default defineConfig({
  base: './',
  plugins: [vue(), vueDevTools()],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
    },
  },
  server: {
    proxy: {
      '/api': {
        target: 'http://122.152.201.203:3000', // 后端服务地址‌:ml-citation{ref="1,2" data="citationList"}
        changeOrigin: true, // 修改请求头Origin为目标地址‌:ml-citation{ref="5,7" data="citationList"}
        rewrite: (path) => path.replace(/^\/api/, ''), // 路径重写规则‌:ml-citation{ref="2,3" data="citationList"}
      },
    },
  },
})
